#include <iostream>

class Complex
{
private:
    int real;
    int vir;

public:
    Complex(int real, int vir):real(real),vir(vir){}
    Complex operator+ (const Complex& c)
    {
        Complex result(0,0);
        result.real = this->real + c.real;
        result.vir = this->vir + c.vir;
        return result;
    }

    Complex operator- (const Complex& c)
    {
        Complex result(0,0);
        result.real = this->real - c.real;
        result.vir = this->vir - c.vir;
        return result;
    }

    //前置
    Complex& operator++()
    {
        this->real++;
        this->vir++;
        return *this;
    }

    //后置 int 占位，区分前置
    Complex operator++(int)
    {
        Complex temp = *this;
        this->real++;
        this->vir++;
        return temp;
    }

    friend std::ostream& operator<< (std::ostream& os, const Complex& c);
    friend std::istream& operator>> (std::istream& is, Complex& c);

    operator int()
    {
        return real;
    }                   
    void show()
    {
        if(vir != 0)
            std::cout<<real<<"+"<<vir<<"i"<<std::endl;
        else    
            std::cout<<real<<std::endl;  
    }
};


std::ostream& operator<< (std::ostream& os, const Complex& c)
{
    if(c.vir != 0)
        os<<c.real<<"+"<<c.vir<<"i"<<std::endl;
    else
        os<<c.real;
    return os;
}

std::istream& operator>> (std::istream& is, Complex& c)
{
    is>>c.real>>c.vir;
    return is;
}

int main()
{
    Complex c(2,0);
    Complex c1(3,0);
    
    //以下两种写法含义相同
    #if 0
    Complex c2 = c.operator+(c1);
    #else
    // Complex c2 = c + c1;
    Complex c2 = c - c1;
    std::cout<<"c2"<<c2<<std::endl;

    int c_num = static_cast<int>(c);
    std::cout<<"c_num:"<<c_num<<std::endl;
    #endif
    // c2.show();

#if 0
    Complex c4(0,0);
    std::cin>>c4;
    std::cout<<c4;
#endif 

    std::cout<<++c1<<std::endl;
    std::cout<<c1<<std::endl;

    return 0;
}